﻿using ConfExpert.Forms.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevTeam;
using System;
using System.Drawing;

namespace ConfExpert.Forms.Aksesuar
{
    public partial class KartTalebiCevap : XForm
    {
        public KartTalebiCevap()
        
        {         
            InitializeComponent();
        }

        private void KartTalebiCevap_Load(object sender, EventArgs e)
        {
            this.Text = "İşlem Görenler";
            gridView1.Init("GetAksesuarKartCevaplananlar");
            gridView1.MakeReadOnly();
            gridView1.MakeColumnInvisible("AksesuarKartTalebiId", "Durum", "Yeni");
            gridView1.BestFitColumns();
            gridView1.RowStyle += gridView1_RowStyle;
            btnGuncelle.ItemClick += btnGuncelle_ItemClick;
        }

        void btnGuncelle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView1.RefreshDataSource("GetAksesuarKartCevaplananlar");
            gridView1.BestFitColumns();
        }

        void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            GridView gvAksesuar = sender as GridView;

            if (gvAksesuar.GetRowCellValue(e.RowHandle, "Durum") != null)
            {
                if (gvAksesuar.GetRowCellValue(e.RowHandle, "Durum").ToString() == "True")
                {
                    e.Appearance.ForeColor = Color.Green;
                }
                else if (gvAksesuar.GetRowCellValue(e.RowHandle, "Durum").ToString() == "False")
                {
                    e.Appearance.ForeColor = Color.Red;
                }
            }
        }
    }
}
